from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from django.conf import settings as django_settings

from userena.models import UserenaBaseProfile
from image_cropping import ImageCropField, ImageRatioField
from guardian.models import UserObjectPermissionBase
from guardian.models import GroupObjectPermissionBase

from h3.utils import upload_to_avatar

class Profile(UserenaBaseProfile):
    """ User Profile Class
    """
    
    user = models.OneToOneField(User,
                                unique=True,
                                verbose_name=_('user'),
                                related_name='my_profile')
    nick_name = models.CharField(_('nick name'),
                                max_length=50,
                                null=True,
                                blank=True)
    avatar = ImageCropField(blank=True,
                            null=True,
                            upload_to=upload_to_avatar)
    avatar_cropping = ImageRatioField('avatar', django_settings.PROFILE_AVATAR_SIZE)

class ProfileUserObjectPermission(UserObjectPermissionBase):
    content_object = models.ForeignKey(Profile)

class ProfileGroupObjectPermission(GroupObjectPermissionBase):
    content_object = models.ForeignKey(Profile)